local QI = DailyIntake.QuestItems;
local Localize = DailyIntake.Localize;

-- Add item: Attuned Crystal Cores; http://www.wowhead.com/?item=34368
local function AttunedCrystalCores()
    return not UnitOnTaxi("player")
        and GetZoneText() == Localize("Isle of Quel'Danas")
        
        -- must target dead Erratic Sentry (http://www.wowhead.com/?npc=24972)
        and not QI.UnitIsTappedByOtherPlayer("target")
        and UnitIsDead("target")
        and QI.UnitIsEntity("target", 24972, QI.Entity.Mob)
        
        -- must not have completed quest objective yet
        and not (QI.QuestIsDone(11524) or -- Erratic Behavior (http://www.wowhead.com/?quest=11524)
                 QI.QuestIsDone(11524) -- Further Conversions (http://www.wowhead.com/?quest=11525)
                 );
end;
QI.RegisterQuestItem(34368, QI.Priority.Highest, AttunedCrystalCores);

-- Add item: Astromancer's Crystal; http://www.wowhead.com/?item=34533
local function AstromancersCrystal()
    return not UnitOnTaxi("player")
        and GetZoneText() == Localize("Isle of Quel'Danas")
        
        -- must be in correct location for an objective of quest (Know Your Ley Lines http://www.wowhead.com/?quest=11547)
        and ((QI.PlayerIsCloseTo(0.48501101136208, 0.44425591826439, 0.006) and not QI.QuestObjectiveIsDone(11547, 1)) or -- Portal
             (QI.PlayerIsCloseTo(0.61196535825729, 0.625359416008, 0.006) and not QI.QuestObjectiveIsDone(11547, 2)) or -- Portal
             (QI.PlayerIsCloseTo(0.42027741670609, 0.35619381070137, 0.007) and not QI.QuestObjectiveIsDone(11547, 3)) -- Bloodcrystal
            );
end;
QI.RegisterQuestItem(34533, QI.Priority.High, AstromancersCrystal);

-- Add item: Shattered Sun Banner; http://www.wowhead.com/?item=34414
local function ShatteredSunBanner()
    return not UnitOnTaxi("player")
        and GetZoneText() == Localize("Isle of Quel'Danas")
        
        -- must target dead Emissary of Hate (http://www.wowhead.com/?npc=25003)
        and not QI.UnitIsTappedByOtherPlayer("target")
        and UnitIsDead("target")
        and QI.UnitIsEntity("target", 25003, QI.Entity.Mob)
        
        -- must not have completed quest objective yet
        and not (QI.QuestObjectiveIsDone(11538, 1) or -- The Battle for the Sun's Reach Armory (http://www.wowhead.com/?quest=11538)
                 QI.QuestObjectiveIsDone(11537, 1) -- The Battle Must Go On (http://www.wowhead.com/?quest=11537)
                 );
end;
QI.RegisterQuestItem(34414, QI.Priority.Highest, ShatteredSunBanner);

-- Add item: Flaming Oil; http://www.wowhead.com/?item=34489
local function FlamingOil()
    return UnitOnTaxi("player")
        and GetZoneText() == Localize("Isle of Quel'Danas")
        
        -- must be in propper area
        and QI.PlayerIsInArea(0.06, 0.4, 0.25, 0.6)
        
        -- must not have completed quest objective yet
        and not ((QI.QuestObjectiveIsDone(11542, 1) and 
                  QI.QuestObjectiveIsDone(11542, 2) and
                  QI.QuestObjectiveIsDone(11542, 3)) or 
                 (QI.QuestObjectiveIsDone(11543, 1) and 
                  QI.QuestObjectiveIsDone(11543, 2) and
                  QI.QuestObjectiveIsDone(11543, 3))
                  );
end;
QI.RegisterQuestItem(34489, QI.Priority.High, FlamingOil);

-- Add item: ManaRemnants; http://www.wowhead.com/?item=34338
local function ManaRemnants()
    return not UnitOnTaxi("player")
        and GetZoneText() == Localize("Isle of Quel'Danas")
        
        -- must have 4 x [Mana Remnants]
        and GetItemCount(34338) >= 4
        
        -- must not have completed the quest
        and not (QI.QuestIsDone(11496) or QI.QuestIsDone(11523))
        
        -- must be at one of the crystals
        and (QI.PlayerIsCloseTo(0.49124637246132, 0.29462558031082, 0.009) or
             QI.PlayerIsCloseTo(0.47490000724792, 0.33658114075661, 0.009) or
             QI.PlayerIsCloseTo(0.46538835763931, 0.35283729434013, 0.009) or
             QI.PlayerIsCloseTo(0.47492098808289, 0.36833292245865, 0.009) or
             QI.PlayerIsCloseTo(0.48636838793755, 0.35440069437027, 0.009) or
             QI.PlayerIsCloseTo(0.5004466176033, 0.3356607854366, 0.009) or
             QI.PlayerIsCloseTo(0.51121187210083, 0.35687604546547, 0.009) or
             QI.PlayerIsCloseTo(0.50291329622269, 0.38194954395294, 0.009) or
             QI.PlayerIsCloseTo(0.51273649930954, 0.39842227101326, 0.009) or
             QI.PlayerIsCloseTo(0.50389248132706, 0.42377132177353, 0.009) or
             
             QI.PlayerIsCloseTo(0.48934319615364, 0.39143061637878, 0.009) or
             QI.PlayerIsCloseTo(0.53719592094421, 0.3621313273906, 0.009)
            );
end;
QI.RegisterQuestItem(34338, QI.Priority.Normal, ManaRemnants);

-- Add item: Arcane Charges; http://www.wowhead.com/?item=34475
local function ArcaneCharges()
    return UnitOnTaxi("player")
        and GetZoneText() == Localize("Isle of Quel'Danas")
        and GetSubZoneText() == Localize("Dead Scar")
        
        -- must not have completed the quest yet
        and not (QI.QuestIsDone(11532) or QI.QuestIsDone(11533));
end;
QI.RegisterQuestItem(34475, QI.Priority.High, ArcaneCharges);

-- Add item: Orb of Murloc Control; http://www.wowhead.com/?item=34483
local function OrbOfMurlocControl()
    return not UnitOnTaxi("player")
        and GetZoneText() == Localize("Isle of Quel'Danas")
        and GetSubZoneText() == Localize("Greengill Coast")
        
        -- must not have completed the quest yet
        and not QI.QuestIsDone(11541);
end;
QI.RegisterQuestItem(34483, QI.Priority.Normal, OrbOfMurlocControl);